<template>
	<view class="bg-white relative">
		<view class="u-page__item">
			<u-collapse accordion :border="false" @open="openCollapse" ref="collapseHeight">
				<u-collapse-item :title="item.text" :name="item.value">
					<!-- <text slot="value" class="u-page__item__title__slot-title"></text> -->
					<view class="u-collapse-content">
						<view class="u-collapse-content" style="padding: 10rpx 30rpx 0; background-color: #FBFBFB;" v-for="(item, index) in list" :key="index">
							<view class="bg-white" style="padding: 20rpx; margin-bottom: 10rpx;">
								<view class="Grid Grid--center Grid--justifyCenter text-xs"
									style="margin-bottom: 30rpx;">
									<view class="Grid-cell" style="color: #666666;">{{item.match_date}} {{item.match_week}}</view>
									<view style="color: #0DA15E;" @click.stop="() => {
										$emit('analysis', item)
									}">查看明细</view>
								</view>
								<view class="Grid Grid--center Grid--justifyCenter text-xs">
									<view class="Grid-cell Grid Grid--center">
										<view>发布数：<text style="color: #0DA15E;">{{item.match_count}}</text></view>
										<view style="padding-left: 60rpx;">命中数：<text
												style="color: #0DA15E;">{{item.accuracy}}</text></view>
									</view>
									<view>命中率：<text style="color: #0DA15E;">{{item.rate}}</text></view>
								</view>
							</view>
						</view>
					</view>
				</u-collapse-item>
			</u-collapse>
		</view>
	</view>
</template>

<script>
	import {
		history
	} from '@/service/index.js'
	
	export default {
		name: 'Item',
		props: {
			item: {
				type: Object,
				default: () => {}
			}
		},
		data() {
			return {
				list: []
			}
		},
		methods: {
			async openCollapse(activeNames) {
				try {
					const {
						data
					} = await history({
						date: activeNames
					})
					this.list = data
					this.$nextTick(() => {
						this.$refs.collapseHeight.init();
					})
				} catch (e) {
					// TODO handle the exception
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	::v-deep .u-collapse-item__content__text {
		padding: 12px 0 !important;
	}
</style>